package c.j.a.d.a.j;

import android.content.Context;
import android.content.pm.PackageInfo;
import android.text.TextUtils;
import c.j.a.c.m.d;
import c.j.a.d.a.h;
import c.j.a.d.a.h.g;
import c.j.a.d.a.i;
import c.j.a.d.b.d.r;
import c.j.a.d.b.o.c;
import java.io.File;

/* compiled from: DownloadNotificationListener */
public class b extends r {
    public Context b;
    public int c;
    public String d;
    public String e;
    public String f;
    public String g;
    public c h;

    /* compiled from: DownloadNotificationListener */
    public class b implements Runnable {
        public final /* synthetic */ com.ss.android.socialbase.downloader.g.c a;
        public final /* synthetic */ int b;

        public b(com.ss.android.socialbase.downloader.g.c cVar, int i) {
            this.a = cVar;
            this.b = i;
        }

        public void run() {
            d dVar = i.j().b;
            c.j.a.d.b.d.d l = c.j.a.d.b.e.i.a(b.this.b).l(this.a.g0());
            if (dVar != null || l != null) {
                com.ss.android.socialbase.downloader.g.c cVar = this.a;
                File file = new File(cVar.e, cVar.b);
                if (file.exists()) {
                    try {
                        PackageInfo c = c.j.a.c.y.a.i.c(b.this.b, file, h.a());
                        if (c != null) {
                            String str;
                            if (this.b == 1 || TextUtils.isEmpty(this.a.w)) {
                                str = c.packageName;
                            } else {
                                str = this.a.w;
                            }
                            if (dVar != null) {
                                int g0 = this.a.g0();
                                long j = this.a.X;
                                dVar.a(g0, 1);
                            }
                            if (l != null) {
                                l.J(1, this.a, str, "");
                            }
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            }
        }
    }

    /* compiled from: DownloadNotificationListener */
    public class a implements g {
        public final /* synthetic */ com.ss.android.socialbase.downloader.g.c a;

        public a(com.ss.android.socialbase.downloader.g.c cVar) {
            this.a = cVar;
        }

        public void a() {
            b.this.g(this.a);
        }
    }

    public b(Context context, int i, String str, String str2, String str3, String str4) {
        if (context != null) {
            this.b = context.getApplicationContext();
        } else {
            this.b = c.j.a.d.b.e.b.a();
        }
        this.c = i;
        this.d = str;
        this.e = str2;
        this.f = str3;
        this.g = str4;
    }

    /* access modifiers changed from: private */
    /* JADX WARNING: Removed duplicated region for block: B:21:0x0043  */
    /* JADX WARNING: Missing block: B:24:0x0053, code skipped:
            if (r5.u.equals("application/vnd.android.package-archive") != false) goto L_0x0066;
     */
    public void g(com.ss.android.socialbase.downloader.g.c r5) {
        /*
        r4 = this;
        r0 = r5.J();
        if (r0 == 0) goto L_0x0011;
    L_0x0006:
        r0 = r5.h;
        r0 = c.j.a.d.a.h.o(r0);
        if (r0 != 0) goto L_0x0011;
    L_0x000e:
        super.D(r5);
    L_0x0011:
        r0 = r5.g0;
        r1 = 1;
        r2 = 0;
        if (r0 == 0) goto L_0x001b;
    L_0x0017:
        r0 = r5.i0;
        if (r0 == 0) goto L_0x0055;
    L_0x001b:
        r0 = r5.h;
        r3 = android.text.TextUtils.isEmpty(r0);
        if (r3 == 0) goto L_0x0025;
    L_0x0023:
        r0 = 0;
        goto L_0x0041;
    L_0x0025:
        r3 = new org.json.JSONObject;	 Catch:{ JSONException -> 0x003c }
        r3.<init>(r0);	 Catch:{ JSONException -> 0x003c }
        r0 = "bind_app";
        r0 = r3.optBoolean(r0, r2);	 Catch:{ JSONException -> 0x003c }
        if (r0 != 0) goto L_0x003a;
    L_0x0032:
        r0 = "auto_install_with_notification";
        r0 = r3.optBoolean(r0, r1);	 Catch:{ JSONException -> 0x003c }
        if (r0 != 0) goto L_0x0023;
    L_0x003a:
        r0 = 1;
        goto L_0x0041;
    L_0x003c:
        r0 = move-exception;
        r0.printStackTrace();
        goto L_0x0023;
    L_0x0041:
        if (r0 != 0) goto L_0x0055;
    L_0x0043:
        r0 = r5.u;
        r0 = android.text.TextUtils.isEmpty(r0);
        if (r0 != 0) goto L_0x0055;
    L_0x004b:
        r0 = r5.u;
        r3 = "application/vnd.android.package-archive";
        r0 = r0.equals(r3);
        if (r0 != 0) goto L_0x0066;
    L_0x0055:
        r0 = r5.g0();
        r0 = c.j.a.d.b.l.a.d(r0);
        r3 = "auto_install_when_resume";
        r0 = r0.b(r3, r2);
        if (r0 == r1) goto L_0x0066;
    L_0x0065:
        r1 = 0;
    L_0x0066:
        if (r1 == 0) goto L_0x0073;
    L_0x0068:
        r0 = r4.b;
        r1 = r5.g0();
        r0 = c.j.a.d.a.h.c(r0, r1, r2);
        goto L_0x0074;
    L_0x0073:
        r0 = 2;
    L_0x0074:
        r1 = c.j.a.d.b.e.b.q();
        r2 = new c.j.a.d.a.j.b$b;
        r2.m2339init(r5, r0);
        r1.execute(r2);
        return;
        */
        throw new UnsupportedOperationException("Method not decompiled: c.j.a.d.a.j.b.g(com.ss.android.socialbase.downloader.g.c):void");
    }

    /* JADX WARNING: Removed duplicated region for block: B:82:0x01ab  */
    /* JADX WARNING: Missing block: B:36:0x008d, code skipped:
            if ((c.j.a.d.b.l.a.d(r8).b("install_guide_xiaomi", 1) == 1 ? 1 : null) != null) goto L_0x00d7;
     */
    /* JADX WARNING: Missing block: B:43:0x00a5, code skipped:
            if ((c.j.a.d.b.l.a.d(r8).b("install_guide_kllk", 1) == 1 ? 1 : null) != null) goto L_0x00d7;
     */
    /* JADX WARNING: Missing block: B:50:0x00bd, code skipped:
            if ((c.j.a.d.b.l.a.d(r8).b("install_guide_vivo", 1) == 1 ? 1 : null) != null) goto L_0x00d7;
     */
    /* JADX WARNING: Missing block: B:57:0x00d5, code skipped:
            if ((c.j.a.d.b.l.a.d(r8).b("install_guide_huawei", 1) == 1 ? 1 : null) != null) goto L_0x00d7;
     */
    /* JADX WARNING: Missing block: B:58:0x00d7, code skipped:
            r0 = 1;
     */
    public void D(com.ss.android.socialbase.downloader.g.c r19) {
        /*
        r18 = this;
        r1 = r18;
        r2 = r19;
        if (r2 == 0) goto L_0x01f5;
    L_0x0006:
        r0 = r1.b;
        if (r0 != 0) goto L_0x000c;
    L_0x000a:
        goto L_0x01f5;
    L_0x000c:
        r0 = r2.u;
        r0 = android.text.TextUtils.isEmpty(r0);
        r3 = 1;
        r4 = 0;
        if (r0 != 0) goto L_0x0022;
    L_0x0016:
        r0 = r2.u;
        r5 = "application/vnd.android.package-archive";
        r0 = r0.equals(r5);
        if (r0 == 0) goto L_0x0022;
    L_0x0020:
        r5 = 1;
        goto L_0x0023;
    L_0x0022:
        r5 = 0;
    L_0x0023:
        if (r5 == 0) goto L_0x0050;
    L_0x0025:
        r0 = r19.g0();
        r0 = c.j.a.d.b.l.a.d(r0);
        r6 = "back_miui_silent_install";
        r0 = r0.b(r6, r3);
        if (r0 != r3) goto L_0x0037;
    L_0x0035:
        r0 = 0;
        goto L_0x004e;
    L_0x0037:
        r0 = c.j.a.d.b.n.d0.j();
        if (r0 != 0) goto L_0x0044;
    L_0x003d:
        r0 = c.j.a.d.b.n.d0.k();
        if (r0 != 0) goto L_0x0044;
    L_0x0043:
        goto L_0x0035;
    L_0x0044:
        r0 = r1.b;
        r6 = "com.miui.securitycore";
        r7 = "com.miui.enterprise.service.EntInstallService";
        r0 = c.j.a.c.y.a.i.q(r0, r6, r7);
    L_0x004e:
        r6 = r0;
        goto L_0x0051;
    L_0x0050:
        r6 = 0;
    L_0x0051:
        r0 = c.j.a.d.a.i.j();
        r7 = r0.h;
        if (r7 == 0) goto L_0x01ad;
    L_0x0059:
        r0 = c.j.a.c.g.y.u();
        if (r0 != 0) goto L_0x0061;
    L_0x005f:
        goto L_0x01a8;
    L_0x0061:
        r8 = r19.g0();
        r0 = c.j.a.d.b.l.a.d(r8);
        r9 = "install_guide_switch";
        r0 = r0.b(r9, r4);
        if (r0 != r3) goto L_0x0073;
    L_0x0071:
        r0 = 1;
        goto L_0x0074;
    L_0x0073:
        r0 = 0;
    L_0x0074:
        if (r0 != 0) goto L_0x0078;
    L_0x0076:
        goto L_0x00d9;
    L_0x0078:
        r0 = c.j.a.d.b.n.d0.d();
        if (r0 == 0) goto L_0x0090;
    L_0x007e:
        r0 = c.j.a.d.b.l.a.d(r8);
        r9 = "install_guide_xiaomi";
        r0 = r0.b(r9, r3);
        if (r0 != r3) goto L_0x008c;
    L_0x008a:
        r0 = 1;
        goto L_0x008d;
    L_0x008c:
        r0 = 0;
    L_0x008d:
        if (r0 == 0) goto L_0x0090;
    L_0x008f:
        goto L_0x00d7;
    L_0x0090:
        r0 = c.j.a.d.b.n.d0.f();
        if (r0 == 0) goto L_0x00a8;
    L_0x0096:
        r0 = c.j.a.d.b.l.a.d(r8);
        r9 = "install_guide_kllk";
        r0 = r0.b(r9, r3);
        if (r0 != r3) goto L_0x00a4;
    L_0x00a2:
        r0 = 1;
        goto L_0x00a5;
    L_0x00a4:
        r0 = 0;
    L_0x00a5:
        if (r0 == 0) goto L_0x00a8;
    L_0x00a7:
        goto L_0x00d7;
    L_0x00a8:
        r0 = c.j.a.d.b.n.d0.e();
        if (r0 == 0) goto L_0x00c0;
    L_0x00ae:
        r0 = c.j.a.d.b.l.a.d(r8);
        r9 = "install_guide_vivo";
        r0 = r0.b(r9, r3);
        if (r0 != r3) goto L_0x00bc;
    L_0x00ba:
        r0 = 1;
        goto L_0x00bd;
    L_0x00bc:
        r0 = 0;
    L_0x00bd:
        if (r0 == 0) goto L_0x00c0;
    L_0x00bf:
        goto L_0x00d7;
    L_0x00c0:
        r0 = c.j.a.d.b.n.d0.a();
        if (r0 == 0) goto L_0x00d9;
    L_0x00c6:
        r0 = c.j.a.d.b.l.a.d(r8);
        r9 = "install_guide_huawei";
        r0 = r0.b(r9, r3);
        if (r0 != r3) goto L_0x00d4;
    L_0x00d2:
        r0 = 1;
        goto L_0x00d5;
    L_0x00d4:
        r0 = 0;
    L_0x00d5:
        if (r0 == 0) goto L_0x00d9;
    L_0x00d7:
        r0 = 1;
        goto L_0x00da;
    L_0x00d9:
        r0 = 0;
    L_0x00da:
        if (r0 == 0) goto L_0x01a8;
    L_0x00dc:
        r0 = c.j.a.c.g.y.a();
        r9 = "sp_install_guide";
        r0 = r0.getSharedPreferences(r9, r4);
        r10 = 0;
        r12 = "guide_last_show_time";
        r10 = r0.getLong(r12, r10);
        r12 = java.lang.System.currentTimeMillis();
        r12 = r12 - r10;
        r0 = c.j.a.d.b.l.a.d(r8);
        r10 = 3;
        r11 = "install_guide_interval";
        r0 = r0.b(r11, r10);
        r10 = 86400000; // 0x5265c00 float:7.82218E-36 double:4.2687272E-316;
        r0 = r0 * r10;
        r10 = (long) r0;
        r0 = (r12 > r10 ? 1 : (r12 == r10 ? 0 : -1));
        if (r0 < 0) goto L_0x010a;
    L_0x0108:
        r0 = 1;
        goto L_0x010b;
    L_0x010a:
        r0 = 0;
    L_0x010b:
        if (r0 == 0) goto L_0x01a8;
    L_0x010d:
        r10 = java.util.Calendar.getInstance();
        r11 = java.lang.System.currentTimeMillis();
        r10.setTimeInMillis(r11);
        r0 = c.j.a.d.b.l.a.d(r8);
        r11 = 15;
        r12 = "install_hijack_days";
        r0 = r0.b(r12, r11);
        r11 = r0;
        r12 = 0;
        r13 = 0;
    L_0x0127:
        if (r11 <= 0) goto L_0x018d;
    L_0x0129:
        r14 = r10.getTimeInMillis();
        r0 = c.j.a.c.y.a.i.w(r14);
        r14 = c.j.a.c.g.y.a();
        r15 = java.lang.Integer.valueOf(r4);
        r14 = r14.getSharedPreferences(r9, r4);
        r3 = "{}";
        r0 = r14.getString(r0, r3);
        r3 = new org.json.JSONObject;	 Catch:{ JSONException -> 0x0162 }
        r3.<init>(r0);	 Catch:{ JSONException -> 0x0162 }
        r0 = "key_install_finish";
        r0 = r3.optInt(r0);	 Catch:{ JSONException -> 0x0162 }
        r14 = "key_install_finish_hijack";
        r3 = r3.optInt(r14);	 Catch:{ JSONException -> 0x0162 }
        r14 = new android.util.Pair;	 Catch:{ JSONException -> 0x0162 }
        r0 = java.lang.Integer.valueOf(r0);	 Catch:{ JSONException -> 0x0162 }
        r3 = java.lang.Integer.valueOf(r3);	 Catch:{ JSONException -> 0x0162 }
        r14.<init>(r0, r3);	 Catch:{ JSONException -> 0x0162 }
        goto L_0x016b;
    L_0x0162:
        r0 = move-exception;
        r0.printStackTrace();
        r14 = new android.util.Pair;
        r14.<init>(r15, r15);
    L_0x016b:
        r0 = r14.first;
        r0 = (java.lang.Integer) r0;
        r0 = r0.intValue();
        r13 = r13 + r0;
        r0 = r14.second;
        r0 = (java.lang.Integer) r0;
        r0 = r0.intValue();
        r12 = r12 + r0;
        r14 = r10.getTimeInMillis();
        r16 = 86400000; // 0x5265c00 float:7.82218E-36 double:4.2687272E-316;
        r14 = r14 - r16;
        r10.setTimeInMillis(r14);
        r11 = r11 + -1;
        r3 = 1;
        goto L_0x0127;
    L_0x018d:
        r9 = (double) r12;
        r0 = c.j.a.d.b.l.a.d(r8);
        r11 = 4602678819172646912; // 0x3fe0000000000000 float:0.0 double:0.5;
        r3 = "install_hijack_ratio";
        r11 = r0.a(r3, r11);
        r13 = (double) r13;
        r11 = r11 * r13;
        r0 = (r9 > r11 ? 1 : (r9 == r11 ? 0 : -1));
        if (r0 < 0) goto L_0x01a3;
    L_0x01a1:
        r0 = 1;
        goto L_0x01a4;
    L_0x01a3:
        r0 = 0;
    L_0x01a4:
        if (r0 == 0) goto L_0x01a8;
    L_0x01a6:
        r0 = 1;
        goto L_0x01a9;
    L_0x01a8:
        r0 = 0;
    L_0x01a9:
        if (r0 == 0) goto L_0x01ad;
    L_0x01ab:
        r3 = 1;
        goto L_0x01ae;
    L_0x01ad:
        r3 = 0;
    L_0x01ae:
        if (r3 == 0) goto L_0x01f2;
    L_0x01b0:
        if (r5 == 0) goto L_0x01f2;
    L_0x01b2:
        if (r6 != 0) goto L_0x01f2;
    L_0x01b4:
        r0 = new c.j.a.d.a.j.b$a;
        r0.m6390init(r2);
        java.util.Objects.requireNonNull(r7);
        r3 = c.j.a.c.g$g.d.c.a;
        r3 = r3.b(r2);
        r4 = c.j.a.c.o.b.b.a;
        r5 = "install_guide_show";
        r4.i(r5, r3);
        r2 = r19.g0();
        com.ss.android.downloadlib.guide.install.InstallGuideActivity.c = r0;
        r0 = new android.content.Intent;
        r3 = c.j.a.c.g.y.a();
        r4 = com.ss.android.downloadlib.guide.install.InstallGuideActivity.class;
        r0.<init>(r3, r4);
        r3 = 268435456; // 0x10000000 float:2.5243549E-29 double:1.32624737E-315;
        r0.addFlags(r3);
        r3 = 6;
        r4 = "type";
        r0.putExtra(r4, r3);
        r3 = "download_info_id";
        r0.putExtra(r3, r2);
        r2 = c.j.a.c.g.y.a();
        r2.startActivity(r0);
        goto L_0x01f5;
    L_0x01f2:
        r18.g(r19);
    L_0x01f5:
        return;
        */
        throw new UnsupportedOperationException("Method not decompiled: c.j.a.d.a.j.b.D(com.ss.android.socialbase.downloader.g.c):void");
    }

    public void a(com.ss.android.socialbase.downloader.g.c cVar) {
        if (cVar != null && !h.o(cVar.h)) {
            super.a(cVar);
        }
    }

    public void b(com.ss.android.socialbase.downloader.g.c cVar) {
        if (cVar != null && !h.o(cVar.h)) {
            super.b(cVar);
        }
    }

    public void c(com.ss.android.socialbase.downloader.g.c cVar) {
        if (cVar != null && !h.o(cVar.h)) {
            super.c(cVar);
        }
    }

    public c d() {
        c cVar = this.h;
        if (cVar != null) {
            return cVar;
        }
        Context context = this.b;
        return context != null ? new a(context, this.c, this.d, this.e, this.f, this.g) : cVar;
    }

    public void x(com.ss.android.socialbase.downloader.g.c cVar) {
        if (cVar != null && !h.o(cVar.h)) {
            super.x(cVar);
        }
    }

    public void z(com.ss.android.socialbase.downloader.g.c cVar, com.ss.android.socialbase.downloader.e.a aVar) {
        if (cVar != null && this.b != null && cVar.J() && !h.o(cVar.h)) {
            super.z(cVar, aVar);
        }
    }
}
